.cm-switch {
    position: relative;
    display: inline-flex;
    box-sizing: border-box;
    height: var(--height-control-small);
    min-width: 50px;
    line-height: var(--height-control-small);
    border-radius: 3px;
    background-color: var(--cui-color-fill-0, rgba(0, 0, 0, 0.25));
    cursor: pointer;
    -webkit-transition: all 0.3s;
    transition: all 0.3s;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;

    &.cm-switch-round {
        border-radius: var(--height-control-small);
        .cm-switch-inner {
            border-radius: calc(var(--height-control-small) - 2px);
        }
    }

    .cm-switch-inner {
        font-size: 12px;
        line-height: var(--height-control-small);
        transition: all 0.25s;
    }

    &.cm-switch-loading {
        .cm-switch-inner {
            visibility: hidden;
        }
    }

    &:focus {
        box-shadow: 0 0 0 2px rgba(16, 142, 233, 0.2);
        outline: 0;
    }

    &:active {
        .cm-switch-inner {
            width: 28px;
        }
    }

    &.cm-switch-checked {
        border-color: var(--cm-switch-active-color, var(--cui-color-primary));
        background-color: var(--cm-switch-active-color, var(--cui-color-primary));

        .cm-loading,
        &:after {
            left: 97%;
            margin-left: -19px;
        }

        .cm-loading {
            color: var(--cui-white-color);
        }

        &:active:after {
            margin-left: -25px;
        }

        .cm-switch-inner {
            left: 95%;
            transform: translate(-100%);
        }
    }

    &.cm-switch-disabled {
        cursor: not-allowed;
        background: var(--cui-color-disabled-bg);
        border-color: var(--cui-color-disabled-bg);

        .cm-switch-inner {
            color: rgba(0, 0, 0, 0.25);
            cursor: not-allowed;
        }

        &:focus {
            box-shadow: none;
            outline: none;
        }
    }

    &.cm-switch-large {
        height: 26px;
        line-height: 24px;
        min-width: 56px;

        .cm-switch-inner {
            width: 22px;
            height: 22px;
        }

        .cm-loading {
            width: 22px!important;
            height: 22px!important;
            svg {
                width: 22px!important;
                height: 22px!important;
            }
            top: 2px;
        }

        &:active {
            .cm-switch-inner {
                width: 30px;
            }
        }
    }
    
    &.cm-switch-small {
        height: 14px;
        min-width: 28px;
        line-height: 12px;

        .cm-loading {
            width: 12px!important;
            height: 12px!important;
            top: 1px;
            left: 1px;
            svg {
                width: 12px!important;
                height: 12px!important;
            }
        }

        .cm-switch-inner {
            width: 10px;
            height: 10px;
        }

        .cm-switch-inner-placeholder {
            padding-right: 2px;
        }

        &:active {
            .cm-switch-inner {
                width: 14px;
            }
        }

        &.cm-switch-checked {
            .cm-loading {
                left: 100%;
                margin-left: -12.5px;
            }

            &:active {
                &:after {
                    margin-left: -16.5px;
                }
            }
        }
    }

    .cm-loading {
        width: 18px!important;
        height: 18px!important;
        position: absolute;
        color: var(--cui-color-primary-hover);
        top: 3px;
        left: 3px;
        z-index: 5;
        svg {
            width: 18px!important;
            height: 18px!important;
        }
    }
}

.cm-switch-inner-placeholder {
    display: flex;
    flex-direction: column;
    padding-right: 6px;
    visibility: hidden;
}

.cm-switch-inner-button-placeholder {
    display: inline-block;
    width: 24px;
}

.cm-switch-label {
    white-space: nowrap;
    position: absolute;
    color: #fff;

    &.cm-switch-label-right {
        color: var(--cui-color-text-2);
    }
}

.cm-switch-inner {
    position: absolute;
    left: 0;
    width: calc(var(--height-control-small) - 4px);
    height: calc(var(--height-control-small) - 4px);
    display: inline-flex;
    left: 2px;
    top: 2px;
    border-radius: 2px;
    background-color: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.3), inset 0 0 1px 0 rgba(0, 0, 0, 0.05);
}
.cm-switch-inner-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cm-switch-label-left {
    right: 100%;
    margin-right: 6px;
}
.cm-switch-label-right {
    left: 100%;
    margin-left: 6px;
}